You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: index displayed file line ranges in thread search - #39308
Find in Thread missed the full range on file chips and skipped chips authored with image syntax. Chat and search now share file-position resolution and image-source selection, so a query such as L42–64 finds the chip shown in the viewer’s theme. Find keys its cached results by that theme so a switch updates matches for the same query.
Commit 9246c3235e (main). The counter shows zero matches even though the link displays L42–64. The cause is at packages/shared/src/threadFindText.ts:183. Ran pnpm scenarios:prove scripts/scenarios/thread-find-matches-file-line-range.e2e.ts --base main with the repro test added: it failed in 2 of 2 runs on a clean checkout, with Find in thread counts the displayed line range as a match in the output.
Evidence
Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit
Steps: Find in thread matches the displayed line range of a file link: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /f6fc8a25-72db-4ad6-88a7-43caa6618a7f/mcp:34056cd6-b83c-4695-ad92-52d0508c1b9f; locator.tap getByRole("button", name: /^Agent See/); locator.waitFor locator("[data-user-message-body]") >> getByText("notes.ts · L42–64") → visible; browser.keyboard.press Control+f; locator.fill getByRole("searchbox", name: "Find in thread"); browser.evaluate ; browser.evaluate ; browser.evaluate ; app.screenshot file-range-find-result.
import{expect}from"e2e";import{test,WEB}from"./t3.ts";test("Find in thread matches the displayed line range of a file link",WEB,async({ t3, app, screen, browser })=>{constproject=awaitt3.project("demo",{"src/notes.ts": "// Notes\n".repeat(64)});constthread=awaitt3.thread({
project,title: "File review",messages: ["See [src/notes.ts](src/notes.ts#L42-L64)"],});awaitt3.open(thread);awaitscreen.getByRole("button",/^AgentSee/).tap();awaitbrowser.locator("[data-user-message-body]").getByText("notes.ts · L42–64",{exact: true}).waitFor();awaitbrowser.keyboard.press("Control+f");awaitscreen.getByRole("searchbox","Find in thread").fill("L42–64");try{awaitexpect.poll(()=>browser.evaluate<string>('document.querySelector("[data-thread-find-bar] span[aria-hidden]")?.textContent ?? ""',),{message: "Find in thread counts the displayed line range as a match"},).toBe("1/1");}finally{awaitapp.screenshot("file-range-find-result");}},);
Tests
83f1161148 adds the failing test, alone, before the fix.
pnpm exec vp test run packages/shared/src/threadFindText.test.ts passed on head.
pnpm exec vp run check:changed passed on head.
Not in this change
Single-line and line-and-column links already index their displayed positions.
Editors still open a range at its start line.
Image, video, and audio previews stay out of the file-link index.
An empty message has no file link to index.
Search request errors and response ordering are outside this change.
Desktop uses the web search path.
Mobile displays ranges and has no Find in Thread entry point.
Global message search uses a separate index.
Who did the work
Written by GPT 6.2 Sol, in Codex
Review findings fixed by GPT 6.2 Sol, in Codex
Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
Also reviewed by cubic, run locally by a program, with no score
Reproduction, checks and proof run by a program on base and head, not by an agent
Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol
Reviewing files that changed from the base of the PR and between bf19447 and 2be82b2.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Thread search now indexes displayed file-line ranges and eligible Markdown image file sources. Search extraction and cached results include the active theme. Markdown rendering and link resolution use shared source and position helpers.
Changes: Thread search and Markdown sources
Layer / File(s)
Summary
Shared Markdown source and link resolution packages/shared/src/markdownLinks.ts, packages/shared/src/markdownPipeline.ts, packages/client-runtime/src/markdownImages.ts, apps/web/src/markdown-links.ts, apps/web/src/components/ChatMarkdown.tsx
Shared helpers classify image sources and resolve file links to structured positions. Markdown rendering and link metadata use the shared helpers.
Searchable file positions and image sources packages/shared/src/threadFindText.ts, packages/shared/src/threadFindText.test.ts, scripts/scenarios/thread-find-matches-file-line-range.e2e.ts
Search extraction includes displayed file positions and eligible image sources. Tests cover line ranges, image destinations, and an end-to-end search for a displayed range.
Theme-aware search and cache inputs packages/contracts/src/orchestrationV2.ts, apps/web/src/components/chat/threadFindStore.ts, apps/web/src/components/chat/useThreadFind.ts, apps/server/src/orchestration-v2/ThreadFind.ts, apps/server/src/orchestration-v2/ThreadFind.test.ts
The search input and local selection carry the theme. The server passes it to text extraction, and search cache keys include it. Tests check theme-specific image-source matches.
Find in Thread now matches the full line range shown on file links, including links authored with image syntax, and refreshes results when the theme changes. The behavior is narrowly scoped, and no concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix: index displayed file line ranges in thread search" names the main change. The changeset makes Find in Thread index file-link line ranges such as L42–64, and it also adds theme-keyed ca…
Description check
The description covers the problem, the change, the scope, and the verification steps. It follows the template's section order with Problem, Change, Scope, Verification, and a tests list. It also repo…
Linked Issues check
[#39307] The issue requires Find in Thread to match the line range shown on a file link, for example [src/notes.ts](src/notes.ts#L42-L64) searched as L42–64. At head, markdownThreadFindText in `…
Out of Scope Changes check
The core fix in threadFindText.ts matches the issue. Three additional areas go beyond the literal issue text: (1) image-syntax file chips, handled by chatMarkdownImageSource, `classifyMarkdownImag…
Full details: Title check
Explanation
The title "fix: index displayed file line ranges in thread search" names the main change. The changeset makes Find in Thread index file-link line ranges such as L42–64, and it also adds theme-keyed caching and image-source selection. The title follows a conventional commit format and states the primary fix in plain language.
Full details: Description check
Explanation
The description covers the problem, the change, the scope, and the verification steps. It follows the template's section order with Problem, Change, Scope, Verification, and a tests list. It also reports a reproduction on main and a before/after proof table. It omits the template's Problem section heading, and its Change section is brief. It also gives no explicit statement about why the image-syntax and theme changes belong to the same fix. These gaps are minor. The description also lists authoring tools and reviewer models, which the template asks for, and it gives a scope note explaining exclusions.
Full details: Linked Issues check
Explanation
[#39307] The issue requires Find in Thread to match the line range shown on a file link, for example [src/notes.ts](src/notes.ts#L42-L64) searched as L42–64. At head, markdownThreadFindText in packages/shared/src/threadFindText.ts calls resolveMarkdownFileLink(candidate, cwd) and passes resolved.position to fileLinkLabel. The indexed text therefore contains the displayed range label. Before this change, the code called splitFilePathPosition(target).path and dropped the range. Unit tests for displayed file-line ranges were added in packages/shared/src/threadFindText.test.ts, and an E2E scenario covers the reported steps. The author reports that the scenario fails on base 2ab3b7f59c and passes on head bf194478d1. I did not run the tests. The coding requirement is met by the source change and the added tests.
Full details: Out of Scope Changes check
Explanation
The core fix in threadFindText.ts matches the issue. Three additional areas go beyond the literal issue text: (1) image-syntax file chips, handled by chatMarkdownImageSource, classifyMarkdownImageSource, and shouldRenderMarkdownImageAsFileLink; (2) theme-keyed Find cache entries in useThreadFind.ts, ThreadFind.ts, and the theme field in threadFindStore.ts and orchestrationV2.ts; and (3) the shared link-resolution refactor in markdownLinks.ts, markdownImages.ts, and ChatMarkdown.tsx. These changes have a concrete connection to the issue. An image-syntax chip is a displayed file chip, and the displayed source depends on theme. A cache keyed without theme could return stale matches for the displayed chip. The PR description states that these changes are part of the same fix. No change was found that is clearly unrelated to displayed file-link search. The refactor and theme-keying are broader than the issue's reproduction, so reviewers may want to confirm they are needed for this bug.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Real web client in Chromium, 1280×800, fresh isolated databases and synthetic data on both commits. Seed an 80-line src/notes.ts and replay an assistant reply containing [src/notes.ts](src/notes.ts#L42-L64). Open Find in Thread with Ctrl+F and enter L42–64 (en dash). Repeat for . For a picture element, use L12–24 in light appearance and L42–64 in dark; keep the search open while switching Light → Dark → Light → Dark.
Scenario: Find counts and highlights the displayed file-chip line range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:L100-499 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Find in Thread missed the full range on file chips and skipped chips authored with image syntax. Chat and search now share file-position resolution and image-source selection, so a query such as L42–64 finds the chip shown in the viewer’s theme. Find keys its cached results by that theme so a switch updates matches for the same query.
Fixes #39307
Related: #22035, #21779
Reproduction on main
Commit 9246c3235e (main). The counter shows zero matches even though the link displays L42–64. The cause is at
packages/shared/src/threadFindText.ts:183. Ranpnpm scenarios:prove scripts/scenarios/thread-find-matches-file-line-range.e2e.ts --base mainwith the repro test added: it failed in 2 of 2 runs on a clean checkout, withFind in thread counts the displayed line range as a matchin the output.Evidence
Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit
Steps: Find in thread matches the displayed line range of a file link: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /f6fc8a25-72db-4ad6-88a7-43caa6618a7f/mcp:34056cd6-b83c-4695-ad92-52d0508c1b9f; locator.tap getByRole("button", name: /^Agent See/); locator.waitFor locator("[data-user-message-body]") >> getByText("notes.ts · L42–64") → visible; browser.keyboard.press Control+f; locator.fill getByRole("searchbox", name: "Find in thread"); browser.evaluate ; browser.evaluate ; browser.evaluate ; app.screenshot file-range-find-result.
Proven: the scenario fails on base 2ab3b7f59c and passes on head bf194478d1.
Scenario source:
scripts/scenarios/thread-find-matches-file-line-range.e2e.tsTests
pnpm exec vp test run packages/shared/src/threadFindText.test.tspassed on head.pnpm exec vp run check:changedpassed on head.Not in this change
Who did the work
Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol